<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp" %>
<%@page import="common.web.action.BaseAction"%>
<%@page import="sysman.ConfigAction"%>

<%
	String pidName = request.getParameter("pidName");
	String pid = request.getParameter(pidName);
	String tableName = request.getParameter("tableName");
	String operate = request.getParameter("operate");
	
	ConfigAction.getListData(request);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>列表</title>
		<%@ include file="../../../common/import_common.jsp" %> 
		
		<script type="text/javascript">
			var controller = new BaseController({"contextPath":"${ctx}","idName":"TABLE_NAME","tableName":"${tableName}","pid":"<%=pid%>"});
			if('del' == '<%=operate%>') {//为了删除动作后右键刷新再调用删除方法
				document.location.href = 'treeList.jsp?tableName=<%=tableName%>&<%=pidName%>=<%=pid%>&pidName=<%=pidName%>&orderName=SHOW_ORDER';
			}
		</script>
	</head>

	<body style="min-height: 700px;">

		<form name="queryForm" method="post" action="treeList.jsp">
			<!-- 隐藏域 -->
			<input type="hidden" name="tableName" value="${tableName}" />
			<input type="hidden" name="orderName" value="SHOW_ORDER" />
			<input type="hidden" name="<%=pidName%>" value="<%=pid%>" />
			<input type="hidden" name="pidName" value="<%=pidName%>" />
			
			<div class="show block">
				<!-- 工具栏开始 -->
				<div class="tools">
					<div class="fl">
						<!--  
						<a href="treeEdit.jsp?tableName=${tableName}&<%=pidName%>=<%=pid%>&pidName=<%=pidName%>" class="btn1">新增</a>
						-->
						<a href="javascript:controller.toEdit('treeEdit.jsp?tableName=${tableName}&<%=pidName%>=<%=pid%>&pidName=<%=pidName%>')" class="btn1">修改</a>
						<!--  
						<a href="javascript:controller.doDel('treeList.jsp?tableName=${tableName}&<%=pidName%>=<%=pid%>&pidName=<%=pidName%>')" class="btn1">删除</a>
						-->
						
						<!-- 扩展的功能 -->
						<c:if test="${not empty(buttonMap.NAME) }">
							<jsp:include page="${buttonMap.NAME}" />
						</c:if>
					</div>

					<!-- 搜索条件 -->
					<div class="fr">
						<c:forEach items="${configList}" var="config" varStatus="status" >
							<c:if test="${status.count%4 == 0 }">
								
							</c:if>
							
							<c:if test="${config.IS_SEARCH == 1 }">
								${config.NAME}：
								
								<!-- 日期 -->
								<c:if test="${config.FIELD_TYPE == 'D' }">
									<input name="${config.FIELD_NAME}" class="text" onclick="WdatePicker()" value="${config.SEARCH_VALUE}" />
								</c:if>
								
								<!-- 非日期 -->
								<c:if test="${config.FIELD_TYPE != 'D' && empty(config.EXPRESSION) }">
									<input type="text" name="${config.FIELD_NAME}" value="${config.SEARCH_VALUE}" />
								</c:if>
								<c:if test="${config.FIELD_TYPE != 'D' && not empty(config.EXPRESSION) }">
									<select name="${config.FIELD_NAME}">
										<option value="">--</option>
										<c:forEach items="${config.OPTIONS}" var="dict"  >
											<option value="${dict.CODE}" ${dict.selected}>${dict.NAME}</option>
										</c:forEach>
									</select>
								</c:if>
								&nbsp;
							</c:if>
						</c:forEach>
						
						<a href="javascript:void(document.forms[0].submit())" class="btn1">搜索</a>
					</div>

					<div class="clr"></div>
				</div>
				<!-- 工具栏结束 -->
				
				<div class="table_h">
					<div class="tb f14">列表</div>
				</div>

				<!-- 数据区开始 -->
				<div class="content1">
					<table width="100%" cellspacing="0" cellpadding="0" border="0"
						class="table_2">
						<thead>
							<tr class="tc">
								<c:forEach items="${configList}" var="config" varStatus="status">
									<c:if test="${status.first}">
									<td class="td1" width="5%">
										<input type="checkbox"  onclick="controller.selectAll(this)" />
									</td>
									</c:if> 
									<c:if test="${!status.first && (config.SHOW_TYPE==1 || config.SHOW_TYPE==3)}">
									<td class="td1">${config.NAME}</td>
									</c:if>
									
									<c:set var="listSize" value="${status.count}" scope="request"></c:set>
								</c:forEach>
							</tr>
						</thead>

						<tbody class="tc" >
							<c:forEach items="${pageList}" var="obj">
								<tr>
									<c:forEach items="${configList}" var="config" varStatus="status">
										<c:if test="${status.first}">
										<td width="5%"><input type="checkbox" name="${config.FIELD_NAME}" value="${obj[config.FIELD_NAME]},${obj.FIELD_NAME}" /></td>
										</c:if>
										<c:if test="${!status.first && (config.SHOW_TYPE==1 || config.SHOW_TYPE==3)}">
										
										<!-- 需要根据数据字典来解析 -->
										<c:if test="${not empty(config.EXPRESSION) }">
										<c:set value="DD_${config.FIELD_NAME}" var="ddName" scope="request" /> 
										<td><c:out value="${obj[requestScope.ddName]}" />&nbsp;</td>
										</c:if>
										
										<c:if test="${empty(config.EXPRESSION) }">
										<td><c:out value="${obj[config.FIELD_NAME]}" />&nbsp;</td>
										</c:if>
										
										</c:if>
									</c:forEach>
								</tr>
							</c:forEach>
							
							<tr>
								<td colspan="${listSize}">
									<!-- 分页 -->
								</td>
							</tr>
					
						</tbody>

					</table>
				</div>
				<!-- 数据区结束 -->
			</div>
		</form>

	</body>
</html>